package com.wu.vpdemo;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.wu.vpdemo.databinding.FragmentVideo2Binding;
import com.wu.vpdemo.databinding.FragmentVideoBinding;

/**
 * 作者:吴奎庆
 * <p>
 * 时间:2021/5/20
 * <p>
 * 用途:
 */


public class VideoFragment2 extends Fragment {

    public static Fragment newInstance(int type) {
        VideoFragment2 fragment = new VideoFragment2();
        Bundle bundle = new Bundle();
        bundle.putInt("type", type);
        fragment.setArguments(bundle);
        return fragment;
    }

    FragmentVideo2Binding binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_video_2, container, false);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        int type = getArguments().getInt("type");
        binding.video.setUrl("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");
        binding.video2.setUrl("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");

    }

    @Override
    public void onResume() {
        super.onResume();
        binding.video.start();

    }

    @Override
    public void onPause() {
        super.onPause();
        binding.video.pause();
    }
}
